import logging
import time

import pytest
from anyio.abc import value
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.common.by import By

from cash_pos.constants.common_sequence import EnvCons, LANGUAGE_SEQUENCE, PayWay, PaymentMethod, VipWay, \
    SCREEN_SHOOT_PATH, DineCate, BusinessDiscountType
from cash_pos.model.pay_detail import PayDetail
from cash_pos.model.selected_good import SelectedGood
from cash_pos.page.client.cash_pos import CashPos
from cash_pos.page.common.common_page import CommonPage
from cash_pos.page.order_page.order_list_page import OrderListPage
from cash_pos.page.order_page.order_page import OrderPage
from cash_pos.page.order_page.part_return_page import PartReturnPage
from cash_pos.page.pay_page.pay_out_page import PayOutPage
from cash_pos.page.security_page.activity_page import ActivityPage
from cash_pos.page.security_page.coupon_page import CouponSearchPage
from cash_pos.page.security_page.daily_settlement_page import DailySettlementPage
from cash_pos.page.security_page.login_page import LoginPage
from cash_pos.model.return_goods import ReturnGoods
import inspect

from cash_pos.page.table_page.table_page import TablePage

logger = logging.getLogger(__name__)


class TestDeleteCase(object):

    def test_login(self):
        """
        测试登录
        """
        # 登录
        LoginPage(CashPos()).switch_env(EnvCons.pre.value).switch_language(LANGUAGE_SEQUENCE[0]).business_login(
            applet_id='10021', applet_pwd='123456').clerk_login('6666', '6666')

    def test_get_function_name(self):
        print(f"当前方法名称: {inspect.currentframe().f_code.co_name}")

    def test_part_return_goods(self):
        PartReturnPage(CashPos()).return_meal_from_requirement(good_list=[ReturnGoods(name='宫保鸡丁', number=1)])

    def test_turn_over(self):
        PayOutPage(CashPos()).use_balance('10')

    def test_business_page_insert_number(self):
        PayOutPage(CashPos()).business_page_insert_number(num='10', type=BusinessDiscountType.fixamount.value)

    def test_switch_discount_way(self):
        PayOutPage(CashPos()).switch_discount_way(BusinessDiscountType.fixamount.value)

    def test_return_back(self):
        OrderListPage(CashPos()).return_dishes().entire_back().insert_reason('不想要了') \
            .print_return_report_confirm().action_confirm()

    def test_open_turnover(self):
        DailySettlementPage(CashPos()).turnover_detail('Teapanda')

    def test_return_dish(self):
        back_meal_list = [ReturnGoods(name='⿊糖珍珠奶茶', number=2), ReturnGoods(name='春日套餐', number=1), ReturnGoods(name='⻩⾦椰椰乌⻰', number=2), ReturnGoods(name='茉莉真鲜奶茶', number=2)]
        OrderListPage(CashPos()).return_dishes().part_back().return_meal_from_requirement(back_meal_list) \
            .insert_reason_option('真不想要了') \
            .print_return_label_confirm() \
            .print_statement_label_confirm() \
            .confirm()


    def test_select_activity(self):
        OrderPage(CashPos()).turn_to_activity().switch_activity_first()

    def test_slice(self):
        cash_pos=CashPos()
        OrderPage(cash_pos) \
            .turn_to_activity() \
            .switch_activity('买10增5,客户端为[收银端,点餐端,KIOSK],活动状态为正常,仅会员可用为否,全部商品,不包含多规格')


    def test_random_order(self):
        OrderPage(CashPos()) \
            .random_add_to_cart(count=10)


